#include "timewheel.hpp"

class Test
{
public:
    Test()
    {
        std::cout << "Test()" << std::endl;
    }

    ~Test()
    {
        std::cout << "~Test()" << std::endl;
    }
};

void DelTest(Test *t)
{
    delete t;
}


int main()
{
    TimerWheel tw_second;

    Test *t = new Test();

    tw_second.TimerAdd(666, 3, std::bind(DelTest, t));

    for(int i = 0; i < 2; i++)
    {
        sleep(1);
        tw_second.TimerRefresh(666);
        tw_second.RunTimerTask();
        std::cout << "刷新了一次定时任务" << std::endl;
    }

    tw_second.TimerCancel(666);

    while(1)
    {
        sleep(1);
        std::cout << "======================================" << std::endl;
        tw_second.RunTimerTask();
    }


    return 0;
}